<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>学生表</title>
  <script>
    function validateForm() {
      var no = document.forms["studentForm"]["no"].value;
      var name = document.forms["studentForm"]["name"].value;
      var gender = document.forms["studentForm"]["gender"].value;
      var age = document.forms["studentForm"]["age"].value;
      var dept = document.forms["studentForm"]["dept"].value;

      if (no == "") {
        alert("学号不能为空");
        return false;
      }

      /*
      if (isNaN(no)) {
        alert("学号必须是数字");
        return false;
      }

      if (name == "") {
        alert("姓名不能为空");
        return false;
      }

      if (gender != "男" && gender != "女") {
        alert("性别必须是'男'或'女'");
        return false;
      }

      if (age == "") {
        alert("年龄不能为空");
        return false;
      }
      if (isNaN(age) || age < 0 || parseInt(age) != age) {
        alert("年龄必须是正整数");
        return false;
      }

      if (dept == "") {
        alert("所在系不能为空");
        return false;
      }
      */
    }  
  </script>
</head>

<body>
  <h3>学生表</h3>
  <div class="container">
    <form name="studentForm" onsubmit="return validateForm()" action="#">
      <div>
        <label for="no">学号:</label>
        <input type="text" id="no" name="no" placeholder="请输入学号..">
      </div>
      <div>
        <label for="name">姓名:</label>
        <input type="text" id="name" name="name" placeholder="请输入姓名..">
      </div>
      <div>
        <label for="gender">性别:</label>
        <input type="text" id="gender" name="gender" placeholder="请输入性别..">
      </div>
      <div>
        <label for="age">年龄:</label>
        <input type="number" id="age" name="age" placeholder="请输入年龄..">
      </div>
      <div>
        <label for="dept">所在系:</label>
        <input type="text" id="dept" name="dept" placeholder="请输入所在系..">
      </div>

      <button type="submit">提交</button>
    </form>
  </div>
</body>

</html>